<template>
  <div id="page" class="site">
    <div class="container">
      <div class="login">
        <div class="hero">
          <h1>你好 同学<br>Hello Student</h1>
          <p>如果你没有账号<br>可以<a @click="register">点击这里</a>进行注册.</p>
        </div>
        <div class="main">
          <form action="">
            <p>
              <input type="email" placeholder="账号" v-model="userLogin.userName">
            </p>
            <p class="password">
              <input type="password" v-model="userLogin.userPass" placeholder="密码">
              <i class="ri-eye-off-line"></i>
              <a href="#">找回密码</a>
            </p>
            <p>
              <input type="submit" class="submit" @click="login" value="登录">
            </p>
          </form>
          <div class="options">
            <div class="separator">
              <p>使用其他方式登录</p>
            </div>
            <ul>
              <li><a href="#"><i class="ri-steam-fill ri-2x"></i></a></li>
              <li><a href="#"><i class="ri-playstation-fill ri-2x"></i></a></li>
              <li><a href="#"><i class="ri-xbox-fill ri-2x"></i></a></li>
            </ul>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script setup>

import { ref } from "vue";
import axios from 'axios';
import { useRouter } from "vue-router";
import {ElMessage} from "element-plus";
let router = useRouter();

let userLogin = ref({
  userName: '',
  userPass: ''
})
function login() {
  axios.post("http://localhost:9090/test/login", userLogin.value).then((res) => {
    console.log(res);
    if (res.data) {
      ElMessage({
        message: '登录成功',
        type: 'success',
      })
      router.push('/management/home')
    }
    else {
      ElMessage({
        message: '登陆失败',
        type: 'error',
      })
    }
  }).catch((err) => {
    console.log(err);
  })
}
function register() {

  router.push('/register')
}
</script>



<style scoped>
@import url("https://cdn.jsdelivr.net/npm/remixicon@2.5.0/fonts/remixicon.css");
@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@500&display=swap');

* {
    margin: 0;
    padding: 0;
}

*, ::before::after {
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans SC', sans-serif;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.8;
    color: #333333;
    background-color: #fcfcff;
    user-select: none;
    -webkit-user-drag: none;
}

a {
    text-decoration: none;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
}

ul {
    list-style: none;
}

h1 {
    font-size: 3em;
    font-weight: 700;
    line-height: normal;
    color: black;
}

.site {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
}

.container {
    max-width: 1000px;
    width: 100%;
    padding: 0 30px;
    margin: 0 auto;
}

.login {
    display: flex;
    flex-wrap: wrap;
}

.hero {
    flex: 1 0 66.6666%;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 50px;
    padding: 70px 0;
}

.hero::before {
    content: '';
    position: absolute;
    top: 15%;
    left: 0;
    width: 280px;
    height: 100px;
    background: linear-gradient(to right, #4460f1, #c471ed, #f64f59);
    z-index: -1;
    filter: blur(70px);
}

.hero a {
    font-weight: 500;
    color: #4460f1;
    transition: color .3s;
}

.hero a:hover,
form .password a:hover {
    color: #333333;
    text-decoration: underline;
}

.main {
    flex: 1 0 33.3333%;
}

.main form {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.main form p {
    position: relative;
}

form input {
    font: inherit;
    font-size: 14px;
    width: 100%;
    border: 0;
    outline: 0;
    padding: 0 20px;
    line-height: 60px;
    border-radius: 10px;
    /*修复input 加入padding之后大小变化的问题*/
    box-sizing: border-box;
}

input::placeholder {
    color: #333333;
    font-family: 'Noto Sans SC', sans-serif;
    font-size: inherit;
}

form input:not(.submit) {
    background-color: #f2f4ff;
}

form .password i {
    position: absolute;
    top: calc(60px / 2);
    right: 20px;
    margin-top: -8px;
    line-height: 1;
    color:#9398b3;
    cursor: pointer;
}

form .password a {
    font-size: 13px;
    color:#9398b3;
    float: right;
    margin: 5px 20px 0 0;
}

form input.submit {
    font-weight: 700;
    color: #ffffff;
    background-color: #4460f1;
    box-shadow: #4460f1 0 20px 30px -10px;
    cursor: pointer;
    transition: box-shadow .3s;
}

form input.submit:hover {
    box-shadow: #4460f1 0 10px 30px -10px;
}

.separator {
    position: relative;
    margin: 50px 0 30px;
}

.separator::before {
    content: '';
    position: absolute;
    top: 50%;
    width: 100%;
    height: 1px;
    background-color:#9398b3;
    opacity: .3;
    z-index: 1;
}

.separator p {
    font-size: 14px;
    width: fit-content;
    padding: 0 10px;
    color: #9398b3;
    background-color: #fcfcff;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.options ul {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.options ul li a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 10px;
    background-color: #ffffff;
    box-shadow: #9398b3 0 10px 20px -10px;
    transition: all .3s ease-out;
}

.options ul li a:hover {
    color: #ffffff;
    box-shadow: none;
}
/*用STEAM PSN XBOX替换原先APPLE GOOGLE FACEBOOK图标*/
.options ul li:nth-child(1) a:hover {
    background-color: #171a21;
}

.options ul li:nth-child(2) a:hover {
    background-color: #00439c;
}

.options ul li:nth-child(3) a:hover {
    background-color: #107c10;
}
</style>